﻿using log4net.Core;
using log4net.Layout.Pattern;
using System.IO;

namespace MxWeiXinPF.Common.log
{
    internal sealed class useridPatternConverter : PatternLayoutConverter
    {
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            LogMessage logMessage = loggingEvent.MessageObject as LogMessage;

            if (logMessage != null)
                writer.Write(logMessage.userid);
        }
    }

    internal sealed class platNamePatternConverter : PatternLayoutConverter
    {
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            LogMessage logMessage = loggingEvent.MessageObject as LogMessage;

            if (logMessage != null)
                writer.Write(logMessage.platName);
        }
    }

    internal sealed class modulePatternConverter : PatternLayoutConverter
    {
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            LogMessage logMessage = loggingEvent.MessageObject as LogMessage;

            if (logMessage != null)
                writer.Write(logMessage.module);
        }
    }

    internal sealed class operatingPatternConverter : PatternLayoutConverter
    {
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            LogMessage logMessage = loggingEvent.MessageObject as LogMessage;

            if (logMessage != null)
                writer.Write(logMessage.operating);
        }
    }

    internal sealed class flgValuePatternConverter : PatternLayoutConverter
    {
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            LogMessage logMessage = loggingEvent.MessageObject as LogMessage;

            if (logMessage != null)
                writer.Write(logMessage.flgValue);
        }
    }

    internal sealed class addipPatternConverter : PatternLayoutConverter
    {
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            LogMessage logMessage = loggingEvent.MessageObject as LogMessage;

            if (logMessage != null)
                writer.Write(logMessage.addip);
        }
    }

    internal sealed class remarkPatternConverter : PatternLayoutConverter
    {
        override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            LogMessage logMessage = loggingEvent.MessageObject as LogMessage;

            if (logMessage != null)
                writer.Write(logMessage.remark);
        }
    }
}